/*
 * @Author: jianglijun 
 * @Date: 2019-04-20 21:30:13 
 * @Last Modified by: jianglijun
 * @Last Modified time: 2019-04-21 15:05:49
 */
/*********************** 封装数据库查找，查找,更新,查找 ********************** */
const mysql = require('mysql');
const {dbConfig}=require('./config.js');
const pool  = mysql.createPool(dbConfig);
let obj = {};
obj.q = function(sql,param) {
        return new Promise((resolve,reject) => {
            pool.getConnection(function(err, connection) {
                if(err){
                    reject(err);
                    return;
                }
                connection.query(sql,param, function (error, results, fields) {
                    connection.release();
                    if(err){
                        reject(error);
                        return;
                    }
                    resolve(results);
                })
            })

        })
}
module.exports = obj;
